//2009/08/21 19:17:03
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class SupermarketDiscount
{
public:
    int minAmount(vector <int> goods)
    {
		sort(goods.begin(), goods.end());
		int sum = 0;
		int temp = 0;
		for(int i=0; i<goods.size(); i++)
		{
			if(goods[i] >= 50) sum += goods[i] - 10;
			else
			{
				temp += goods[i];
				cout << "temp: " << temp << endl;
			}
			if(temp >= 50) sum += temp - 10, temp = 0;
		}
		sum += temp;
		return sum;
    }
};

